package rs.networx.entity;

import static javax.persistence.GenerationType.IDENTITY;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name="comments")
public class Comment implements java.io.Serializable {
	
	private static final long serialVersionUID = 818346191L;

	@Id
	@GeneratedValue(strategy=IDENTITY)
	@Column(name="comment_id", unique=true, nullable=false)
	private Integer id;

	@Column(name="date", unique=false, nullable=false)
	private Date date;

	@Column(name="text", unique=false, nullable=false)
	private String text;

	@ManyToOne
	@JoinColumn(name="commetator_id", referencedColumnName="person_id", nullable=false)
	private Person commetator;

	@ManyToOne
	@JoinColumn(name="post_id", referencedColumnName="post_id", nullable=false)
	private Post post;
	
	public Comment() {
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public Person getCommetator() {
		return commetator;
	}

	public void setCommetator(Person commetator) {
		this.commetator = commetator;
	}

	public Post getPost() {
		return post;
	}

	public void setPost(Post post) {
		this.post = post;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public String toString() {
		return "Comment" + " id=" + id + " date=" + date + " text=" + text;
	}

}